package dk.muldbjergskolen.db;

import java.sql.SQLException;
import java.util.List;

import dk.muldbjergskolen.model.Fag;

public class LaererFagDB {
	private ConnectionDB con = ConnectionDB.getInstance();

	/**
	 * Opretter assoceringerne mellem en lærer og fag.
	 * 
	 * @param personId
	 * @param fag
	 */
	public void opretLaererFag(int personId, List<Fag> fag) {
		if (fag == null)
			return;

		for (Fag f : fag) {
			String query = "INSERT INTO LaererFag values (" + personId + ", "
					+ f.getId() + ")";

			try {
				con.execQuery(query);
			} catch (SQLException e) {
				System.out.println("LaererFag.opretLaererFag: "
						+ e.getMessage());
			}
		}
	}
}
